#ifndef _HTMLSTYLE_H_
#define _HTMLSTYLE_H_

#include "declareinc.h"
#include "TRgbEx.h"

namespace Renderer
{
class TLength
{
public:
	enum TLengthUnit
	{
		Pixel = 0,
		Percent,
		Auto
	};

	TLength& operator=(const TDesC& aDes);
	TLength& operator=(TInt aLen);
	TInt RealLength(TInt maxLen) const;

private:
	TInt iVal;
	TLengthUnit iLengthUnit;
};

class TMargin
{
public:
	enum SetFlag
	{
		left = 0,
		right,
		top,
		bottom
	};
private:
	TLength iLeft;
	TLength iRight;
	TLength iTop;
	TLength iBottom;

	TBitFlags8 iFlag;
public:
	TLength Left() const {return iLeft;}
	TLength Right() const {return iRight;}
	TLength Top() const {return iTop;}
	TLength Bottom() const {return iBottom;}

	TInt Left(TInt maxLen) const {return iLeft.RealLength(maxLen);}
	TInt Right(TInt maxLen) const {return iRight.RealLength(maxLen);}
	TInt Top(TInt maxLen) const {return iTop.RealLength(maxLen);}
	TInt Bottom(TInt maxLen) const {return iBottom.RealLength(maxLen);}

	void SetLeft(const TDesC& aDes) {iLeft = aDes; Set(TMargin::left);}
	void SetRight(const TDesC& aDes) {iRight = aDes; Set(TMargin::right);}
	void SetTop(const TDesC& aDes) {iTop = aDes; Set(TMargin::top);}
	void SetBottom(const TDesC& aDes) {iBottom = aDes; Set(TMargin::bottom);}

	TBool IsSet(SetFlag aFlag)
	{
		return iFlag.IsSet(aFlag);
	}
	void Set(SetFlag aFlag)
	{
		iFlag.Set(aFlag);
	}
	void Clear(SetFlag aFlag)
	{
		iFlag.Clear(aFlag);
	}
};

typedef TMargin TPadding;

class TBorderStyle
{
public:
	enum EBorderStyle
	{
		none,
		hidden,
		dotted,
		dashed,
		solid,
		bDouble,
		groove,
		ridge,
		inset ,
		outset
	};

private:
	TLength iLength;
	TRgbEx iRgb;
	EBorderStyle iBorderStyle;
public:
	TInt RealLength(TInt maxLen) {return iLength.RealLength(maxLen);}
public:
	TBorderStyle();
	TBorderStyle& operator=(const TDesC& aDes);

public:
	void GetAttributeType(const TDesC& aDes);
};

class TBorder
{
public:
	enum SetFlag
	{
		left = 0,
		right,
		top,
		bottom
	};
private:
	TBorderStyle iLeft;
	TBorderStyle iRight;
	TBorderStyle iTop;
	TBorderStyle iBottom;

	TBitFlags8 iFlag;

public:
	void SetLeft(const TDesC& aDes) {iLeft = aDes; Set(TBorder::left);}
	void SetRight(const TDesC& aDes) {iRight = aDes; Set(TBorder::right);}
	void SetTop(const TDesC& aDes) {iTop = aDes; Set(TBorder::top);}
	void SetBottom(const TDesC& aDes) {iBottom = aDes; Set(TBorder::bottom);}

	TInt LeftLen(TInt maxLen) {return iLeft.RealLength(maxLen);}
	TInt RightLen(TInt maxLen) {return iRight.RealLength(maxLen);}
	TInt TopLen(TInt maxLen) {return iTop.RealLength(maxLen);}
	TInt BottomLen(TInt maxLen) {return iBottom.RealLength(maxLen);}
public:
	TBool IsSet(SetFlag aFlag)
	{
		return iFlag.IsSet(aFlag);
	}
	void Set(SetFlag aFlag)
	{
		iFlag.Set(aFlag);
	}
	void Clear(SetFlag aFlag)
	{
		iFlag.Clear(aFlag);
	}
};

class HtmlStyle
{
public:
	enum SetFlag
	{
		setDisplay,
		setFloat,
		setPosition	
	};

	enum TDisplay
	{
		DisplayNone,
		DisplayInline,
		DisplayBlock,
		DisplayInline_block
	};

	enum TFloat
	{
		FloatNone,
		FloatLeft,
		FloatRight
	};

	enum TPosition
	{
		PositionStatic,
		PositionAbsolute,
		PositionFixed,
		PositionRelative
	};

public:
	HtmlStyle();
	virtual ~HtmlStyle();

public:
	TMargin iMargin;
	TBorder iBorder;
	TPadding iPadding;
	TLength iWidth;
	TLength iHeight;

	TDisplay iDisplay;
	TFloat iFloat;
	TPosition iPosition;
	TLength iLeft;
	TLength iTop;
	TLength iRight;
	TLength iBottom;
	
private:
	TBitFlags8 iFlag;
public:
	TBool IsSet(SetFlag aFlag)
	{
		return iFlag.IsSet(aFlag);
	}
	void Set(SetFlag aFlag)
	{
		iFlag.Set(aFlag);
	}
	void Clear(SetFlag aFlag)
	{
		iFlag.Clear(aFlag);
	}
};

}

#endif